Default Doc API
This is the skeleton of the "@doc" plugin without much of the main logic for the parsing and rendering methods. This gives you an idea of how documents are parsed, rendered, and grouped. For example, the "layout" configuration provides information for how non-overview documentation can be grouped within a module ('classes', 'globals').
module.exports = { identifier: "doc", //matches @doc our default title: "Default Documentation Handling", /*============ WHAT DOES "MODULE" MEAN FOR THIS TYPE OF CODE? WHAT SECTIONS DO PARENT LEVEL TYPES FALL INTO? ===========*/ // the module title and definition help users understand how code is grouped at the highest level of code organization // the title gets used in the UI so the highest level of grouping would be called whatever the title is layout: { module: { title: "module", getModule: function (id, module) { return module; } }, sections: { "class" : { order: 0, title: "classes", match: function (id, module, section, item, subItem) { return section == "class"; } }, "global": { order: 1, title: "globals", match: function (id, module, section, item, subItem) { return section == "global"; } } } }, /*============ UI RESOURCES TO INJECT IN ORDER (from the base of this doc api plugin) ===========*/ ui_resources : { js : [], css : ['resources/ui/api_ui_styles.css'] }, /*============ HERE WE SETUP CUSTOM KEY VALUE PARSING METHODS ===========*/ // each method will recieve (self, text, Doc), where self is a Doc instance, the text value of the pararm, and reference to the Doc class // the reference to the Doc class is in case you want to create a new Doc instance and nest it within another categor (example properties) // by default if no parse method is found it will attach the key value pair directly to the Doc object parse : { //params need to be added to the params bucket 'param' : function (text) { ... }, //returns should just be added as a property (there should only be one) 'returns' : returnsFunction, 'return' : returnsFunction, //requires should be added to the requires bucket 'requires' : function (text) { ... }, //properties should be added to the properties bucket but generated as a new Doc object 'property' : function (text, Doc) { ... }, //eventType should propogate two properties, the type and target 'eventType' : function (text) { ... } }, /*============ ADD ADDITIONAL MARKDOWN METHODS TO FIND AND REPLACE YOUR OWN SPECIAL MARKDOWN PATTERNS ===========*/ //here we provide as many methods as we wish to find and replace markdown within the text //by default we provide some handy markdown replacements that are interactive within the angular UI //we also run it through Showdown to provide some of the basic markdown replacements markdown : { 'default' : { order: 1, //this should typically be run first to add in the default markdown behavior markdown: function (text, placeholder) { ... } }, 'showdown' : { order: 10, // this typically should be run last markdown: function (text) { ... } } }, /*============ THIS FUNCTION WILL DETERMINE HOW THE TITLE APPEARS AT THE TOP OF THE PAGE ============*/ heading: function (dom) { ... }, /*============ CUSTOM RENDER METHODS FOR USING ALL THE DOC ATTRIBUTES TO SPIT OUT HTML FOR THE PARTIALS ===========*/ html : { parameters: function(dom) { ... }, returns: function(dom) { ... }, this: function(dom) { ... }, function: methodFunction, method: methodFunction, property: function(dom){ ... }, overview: function(dom){ ... }, module: function(dom){ ... }, interface: function(dom){ ... }, object: function(dom) { ... }, /*============= THE FOLLOWING GENERATE HTML BUT ARE NOT CALLED DIRECTLY AS DOC TYPES : THEY ARE HELPERS =============*/ method_properties_events : function(dom) { ... }, parameterParse : function(dom, separator, skipFirst, prefix) { ... } }, // All the default rendering is stored in the Doc.js class. Use this in a new api to // Build upon those defaults render : {} };